package thread.communication;
import static java.lang.System.out;

/**
 * 
 * @author Shahid
 */
public class CallBack implements Runnable {
	
	/*
	 * There is no need to declare array as class field as was required in Polling
	 * Polling need shared data
	 */
	public void run() {
		int[] array = new int[30];
		try {
			for (int j = 0; j < 30; j++) {
				array[j] = j;
				Thread.sleep(1);
			}
		} catch (InterruptedException e) {
			out.println(e.toString());
		}

		receiveCall(array);
	}

	public void receiveCall(int[] a) {
		print(a);
	}

	public static void main(String[] args) throws Exception {
		new Thread(new CallBack()).start();
	}

	static void print(int[] array) {
		for (int i : array) {
			out.print(i + ",");
		}
		out.print("\n");
	}
}

// Output
// 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,